package com.deepface.framework.config;

import javax.websocket.server.ServerEndpointConfig;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @ClassName MyEndpointConfigure
 * @Description
 * @Author 74707
 * @Date 2024/4/1 16:07
 * @Version V1.0
 */

public class MyEndpointConfigure extends ServerEndpointConfig.Configurator implements
    ApplicationContextAware {

  private static volatile BeanFactory context;

  @Override
  public <T> T getEndpointInstance(Class<T> clazz){
    return context.getBean(clazz);
  }

  @Override
  public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    MyEndpointConfigure.context = applicationContext;
  }
}
